#include<iostream>
#include<string>
#include<cstdlib>
#include <cstring>

using namespace std;

//class Solution 
//{
//public:
//    string complexNumberMultiply(string num1, string num2) 
//	{
//		auto end1 =num1.find('+');
//		auto end2 =num1.find('i');
//		string s1(num1,num1.begin(),end1-num1.begin());
//		
//    }
//};
//
//
//int main()
//{
//	Solution s;
//	s.complexNumberMultiply()
//	return 0;
//}


class Solution {
public:
    string complexNumberMultiply(string num1, string num2) 
	{
        //(a + bi)(c + di) = (ac - bd) + (ad + bc)i
        int pos1 = num1.find('+');
        int pos2 = num2.find('+');

        int a = stoi(num1.substr(0, pos1)), b = stoi(num1.substr(pos1+1, num1.size() - pos1-2));
        int c = stoi(num2.substr(0, pos2)), d = stoi(num2.substr(pos2+1, num2.size() - pos2-2));

        string ans = to_string(a*c - b*d) + '+' + to_string(a*d + b*c) + 'i';
        return ans;
        
    }
};

int main()
{
	Solution s;
	s.complexNumberMultiply()
	return 0;
}

